<?php

/**
 * 前台首页
 * @author phills.li
 *
 */
class IndexAction extends Action {

    // 查询数据
    public function index() {
        $this->display();
    }
    
    public function getPeriodList(){
        
        $model = M('period');
        import("ORG.Util.Page");
        $total = $model->count();
        $p = new Page($total);
        
        
        
        $responce = array();
        $responce['page'] = (isset($_GET['page']))?$_GET['page']:1;
        //dump('aaa');
        //exit;
        
        $responce['total'] = $p->totalPages;
        $responce['records'] = $total;
        
        $rows = $model->select();
        $i = 0;
        
        
        foreach($rows as $row){
            $responce['rows'][$i]['id'] = $row['id'];
            $responce['rows'][$i]['cell'] = array($row['id'],
                                                  $row['period_id'],
                                                  $row['result'],
                                                  $row['create_time'],
                                                  $row['update_time'],
                                                  $row['number'],
                                                  
                                                  );
            $i++;
        }
        echo json_encode($responce);
    }
    
    public function getOrderList(){
        $model = M('order');
        import("ORG.Util.Page");
        $total = $model->where('period_id='.$_GET['id'])->count();
        $p = new Page($total);
        
        $responce = array();
        $responce['page'] = (isset($_GET['page']))?$_GET['page']:1;
        $responce['total'] = $p->totalPages;
        $responce['records'] = $total;
        
        $rows = $model->where('period_id='.$_GET['id'])->select();
        
        //dump($model->getLastSql());
        $i = 0;
        foreach($rows as $row){
            $responce['rows'][$i]['id'] = $row['id'];
            $responce['rows'][$i]['cell'] = array($row['id'],
                                                  $row['period_id'],
                                                  $row['all_json'],
                                                  $row['create_time'],
                                                  $row['update_time'],
                                                  $row['label'],
                                                  $row['result'],                                                  
                                                  );
            $i++;
        }
        echo json_encode($responce);
        }
    
    
    public function order() {
        $model = M('type');
        //print_r($model->select());
        $this->display();
    }
    
    public function config() {
        $model = M('type');
        //print_r($model->select());
        $this->display();
    }

}

?>